project(base)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/plugins)

add_compile_options(/wd4819)

include_directories(
    ${Qt5Network_INCLUDE_DIRS}

    ${CTK_INCLUDE_DIRS}

) 

# 获取所有的 .cpp 文件
file(GLOB_RECURSE  SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"

#"${CMAKE_SOURCE_DIR}/src/Base/Common/*.cpp"
)
# 获取所有的 .h 文件
file(GLOB_RECURSE  HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/*.h"
"${CMAKE_SOURCE_DIR}/src/Base/Common/*.h"

)
# 获取所有的资源文件
file(GLOB_RECURSE  RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.qrc")
# 获取所有的 UI 文件
file(GLOB_RECURSE  UI_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.ui")

QT5_WRAP_CPP(MOC_FILES ${HEADERS})

set(CAMERA_3D_APP_SRC
    ${SOURCES}
    ${HEADERS}
    ${RESOURCES}
    ${UI_FILES}
    ${MOC_FILES}
)

message("Build File List:")
foreach(src ${ROBOT_APP_SRC})
    message("  ${src}")
endforeach()

message("Copy Dir:" ${CMAKE_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}/plugins)
link_directories(
if(CMAKE_BUILD_TYPE MATCHES Debug)
    ${CMAKE_SOURCE_DIR}/lib/Debug/
else()
    ${CMAKE_SOURCE_DIR}/lib/Release/
endif()

)

SET(CAMERA_3D_APP_LIBS
    ${Qt5Core_LIBRARIES}
    ${Qt5Gui_LIBRARIES}  
    ${Qt5Widgets_LIBRARIES}   
    ${Qt5Network_LIBRARIES}  
    CTKPluginFramework
 
)

add_library(${PROJECT_NAME} STATIC ${CAMERA_3D_APP_SRC})

#链接库
target_link_libraries(${PROJECT_NAME} PRIVATE
  ${CAMERA_3D_APP_LIBS} 
)

# 添加自定义命令，将生成的 DLL 拷贝到指定目录
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E make_directory
            ${CMAKE_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}/plugins/AppPlugins/${PROJECT_NAME}

    COMMAND ${CMAKE_COMMAND} -E copy
            $<TARGET_FILE:${PROJECT_NAME}>
            ${CMAKE_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}/plugins/AppPlugins/${PROJECT_NAME}

)